package com.hxd.otc.module.convenience.activity;

import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseActivity;
import com.hxd.otc.module.convenience.bean.OrderFinishedBean;
import com.hxd.otc.module.convenience.bean.OrderInfoBean;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.widget.TitleBar;

import butterknife.BindView;

public class OilRechargeFailActivity extends BaseActivity {

    @BindView(R.id.ll_error)
    LinearLayout llError;

    @BindView(R.id.ll_rechargeing)
    LinearLayout llRechargeing;

    @BindView(R.id.ll_finished)
    LinearLayout llFinished;

    @BindView(R.id.tv_content)
    TextView tvContent;

    @BindView(R.id.tv_order_number)
    TextView tvOrderNumber;

    @BindView(R.id.tv_card_number)
    TextView tvCardNumber;

    @BindView(R.id.bt_back)
    Button btBack;

    @BindView(R.id.title_bar)
    TitleBar titleBar;

    OrderInfoBean orderInfoBean;
    OrderFinishedBean orderFinishedBean;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_oil_recharge_fail;
    }

    @Override
    protected void initView() {

        if (getIntent().getExtras().containsKey("orderFinishedBean")) {
            orderFinishedBean = (OrderFinishedBean) getIntent().getExtras().getSerializable("orderFinishedBean");
        }
        orderInfoBean = (OrderInfoBean) getIntent().getExtras().getSerializable("orderInfoBean");

        titleBar.setTitleText(orderInfoBean.getModelTitle() + getString(R.string.recharge));
        switch (getIntent().getExtras().getInt("code", 20000004)) {
            case 20000002://  //充值失败
            case 20000007://  //扣币失败
                llError.setVisibility(View.VISIBLE);
                break;
            case 20000003://扣币中
                llRechargeing.setVisibility(View.VISIBLE);
                break;
            case 20000004://扣费中
                llRechargeing.setVisibility(View.VISIBLE);
                break;
            case 20000005:  //充值中
                llRechargeing.setVisibility(View.VISIBLE);
                break;
            case 100000://充值成功
                llFinished.setVisibility(View.VISIBLE);
                tvContent.setText(orderInfoBean.getGoodsName());
                tvOrderNumber.setText(orderInfoBean.getRechargeAccount());
                if (orderFinishedBean != null)
                    tvCardNumber.setText(orderFinishedBean.orderId);
                break;
        }
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvent() {
        btBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                $startActivity(ConvenienceActivity.class, true);
            }
        });
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
}
